<?php
class HModuleInstanceAdmin {
	function insert($moduleid, $viewfile, $friendlyname, $created_date = null, $created_user = null, $modified_date = null, $modified_user = null) {
		try {
			HSql::doQuery("
				INSERT INTO 
					portal_modules_instances(module_id, view_file, friendly_name, created_date, created_user, modified_date, modified_user)
				VALUES(
					'$moduleid',
					'$viewfile',
					'$friendlyname',
					'$created_date',
					'$created_user',
					'$modified_date',
					'$modified_user'
				)
			");
		}
		catch (Exception $ex) {
			throw new Exception($ex->getMessage());
		}
	}
	
	function update($id, $viewfile, $friendlyname, $modified_date = null, $modified_user = null) {
		try {
			HSql::doQuery("
				UPDATE portal_modules_instances
				SET 	view_file = '$viewfile',
						friendly_name = '$friendlyname',
						modified_date = '$modified_date',
						modified_user = '$modified_user'						
				WHERE id = '$id'
			");
		}
		catch (Exception $ex) {
			throw new Exception($ex->getMessage());
		}
	}
	
	function delete($id) {
		try {
			HSql::doQuery("
				DELETE FROM portal_modules_instances
				WHERE id = '$id'
			");
		}
		catch (Exception $ex) {
			throw new Exception($ex->getMessage());
		}
	}
}